package com.winai.launcher.common;

import android.app.Activity;

/*
 * 全局发布器
 * 用于业务解耦
 */

public class GlobalPublisher {
    public static final int ANY = SignalSlot.CARE_ANY;

    public static final int LOGOUT = -1;//退出登录
    public static final int CHANGE_VOICE = 11;//改变音量
    public static final int CHANGE_WIFI = 13;//改变Wifi
    public static final int CHANGE_SCREENPROTECT = 14;//改变屏保
    public static final int LINK_WIFI = 2;//连接Wifi
    public static final int CHANGE_NETWORK = 21;//无网络连接
    public static final int LINK_CONFIG_WIFI = 20;//连接初次配置Wifi
    public static final int REMOVE_BOND_BLUETOOTH = 30;//解除绑定蓝牙
    public static final int BOND_BLUETOOTH = 31;//绑定蓝牙
    public static final int CHANGE_ALARM_CLOCK = 33;//改变了闹钟
    public static final int CLOSE_ALARM_CLOCK = 34;//关闭了闹钟
    public static final int CLOSE_ALARM_UI = 35;//关闭了闹钟UI

    public static final int DOWNLOAD_ROM_COMPLETE = 40;//版本下载完毕
    public static final int DOWNLOAD_ROM_FAIL = 41;//版本下载失败

    public static final int BLUETOOTH_DEVICE_DISCONNECTED = 54;//蓝牙设备已断开
    public static final int BLUETOOTH_STATE_ON = 55;//蓝牙打开
    public static final int BLUETOOTH_STATE_OFF = 56;//蓝牙关闭

    public static final int OPEN_CALENDAR = 60;//打开日历
    public static final int OPEN_ALARM = 61;//打开闹钟

    public static final int WEATHER_UPDATE = 70;//天气信息更新
    public static final int WEATHER_UPDATE_FOR_WEATHER_CENTER = 71;//天气中心信息更新

    public static final int NETWORK_AVAILABLE = 100;//网络连接有效
    public static final int NETWORK_LOST = 101;//网络断开

    public static final int CHANGE_VOICE_RECEIVER = 111;//音量改变广播接收
    public static final int CHANGE_LIGHT_RECEIVER = 222;//亮度改变广播接收
    private static SignalSlot.Signaler gSignalGlobal = new SignalSlot.Signaler();

    //设置接收器
    public static boolean setListener(int care, SignalSlot.Slot slot) {
        return setListener(care, null, slot);
    }

    //设置activity的接收器
    public static boolean setListener(int care, Activity activity, SignalSlot.Slot slot) {
        return gSignalGlobal.addSolt(care, activity, slot);
    }

    /**
     * @Desc 移除接收器(需要在activity finish之前移除接收器)
     */
    public static void removeListener(Activity activity) {
        gSignalGlobal.removeSlot(activity);
    }

    /**
     * @Desc 发送通知
     */
    public static void Notify(int what) {
        Notify(what, 0);
    }

    //发送通知
    public static void Notify(int what, int arg1) {
        Notify(what, arg1, 0);
    }

    //发送通知
    public static void Notify(int what, int arg1, int arg2) {
        Notify(what, arg1, arg2, null);
    }

    //发送通知
    public static void Notify(int what, Object argObj) {
        Notify(what, 0, 0, argObj);
    }

    //发送通知
    public static void Notify(int what, int arg1, int arg2, Object argObj) {
        gSignalGlobal.signal(what, arg1, arg2, argObj);
    }
}
